﻿Imports System.Drawing
Imports System.Drawing.Imaging

Namespace AdvanceWars.Data
    ''' <summary>
    ''' 图像服务器
    ''' </summary>
    Public NotInheritable Class ImageService

        Shared Sub New()
            Units = My.Resources.unit_00.Splite(16, 16)
            Terrains = My.Resources.terrain_00.Splite(16, 16)
            Cities = My.Resources.building_00.Splite(16, 32)
        End Sub

        Public Shared ReadOnly Units As IEnumerable(Of Bitmap)
        Public Shared ReadOnly Cities As IEnumerable(Of Bitmap)
        Public Shared ReadOnly Terrains As IEnumerable(Of Bitmap)

        Public Shared Function GetUnit(ByVal id As Integer, ByVal country As Country) As Bitmap
            Dim row As Integer = (country - 1) * 2 + IIf(id > 12, 1, 0)
            Dim column As Integer = IIf(id > 12, id - 12, id)
            Dim index As Integer = row * 13 + column
            Return Units(index)
        End Function

    End Class
End Namespace